package de.sane.manager

import scala.swing.Publisher

trait ListManager[T] extends Manager[List[T]] {
	this: Publisher =>

	def initial: List[T] = List()

	def map(func: T => T): ListManager[T] = {
		this.transform(a => a.map(func))
		this
	}
	
	def filter(func: T => Boolean): ListManager[T] = {
		this.transform(a => a.filter(func))
		this
	}
	
	def add(value: T): ListManager[T] = {
		this.transform(a => value :: a)
		this
	}
	
	def remove(value: T): ListManager[T] = {
		this.transform(a => a - value)
		this
	}
	
	def clear(): ListManager[T] = {
		this.transform(a => List[T]())
		this
	}
}